import React, {Component} from 'react';

class Demo02 extends Component {
  constructor (props) {
    super(props);
    this.state = {};
  }
  handleClick () {
    if (this.myTextInput !== null) {
      this.myTextInput.focus();
      // console.log(this.myTextInput);
    }
  }

  render () {
    return (
      <div>
        <input type="text" ref={(ref) => {
          // console.log('ref', ref)
          this.myTextInput = ref
        }}/>
        <input type="button" value="Focus the text input" onClick={this.handleClick.bind(this)}/>
      </div>
    );
  }
}

export default Demo02;
